package VacationTest.PlaneFight.src;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.Serial;

public class Gameover{
    static GameFrame frame;

    public static class MyFrame extends JFrame {	//创建新类，继承自JFrame
        @Serial
        private  static final long serialVersionUID = 1L;
        public MyFrame() {
            Container container = getContentPane();	//创建一个容器
            container.setLayout(null);
            //JLabel jl = new JLabel("这是一个JFrame窗体");	//在窗体中设置标签
            //jl.setHorizontalAlignment(SwingConstants.CENTER);	//将标签的文字至于标签中间的位置
            //container.add(jl);	//将标签添加到容器中
            JButton jb = new JButton("game over");	//定义一个按钮
            ImageIcon img = new ImageIcon("E:\\JavaCode\\AirWar\\src\\VacationTest\\PlaneFight\\Image\\Gameover.jpg");
            img.setImage(img.getImage().getScaledInstance(350,150,0));
            jb.setBounds(0, 0, 350, 150);	//设置按钮的大小
            jb.setIcon(img);
            jb.addActionListener(new ActionListener() {	//为按钮添加点击事件

                @Override
                public void actionPerformed(ActionEvent e){
                    try {
                        Thread.sleep(1500);
                    } catch (InterruptedException e1) {
                        // TODO Auto-generated catch block
                        e1.printStackTrace();
                    }
                    System.exit(0);
                }
            });
            container.add(jb);
            setSize(360,180);
            setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
            setVisible(true);
            setLocationRelativeTo(null);//设置窗口 相对于屏幕的位置，null 指：处于屏幕中央
        }

    }
}

